#include <iostream>
#include <cstdio>
#include <map>
#include <string>

using namespace std;

const int N = 14;

int g[30][30];

string str = "0123456789abcdef";

void setArea(int x, int y, int n, int w, int inc) {
    for (int i = 0; i < (n - 1 - w); i++) {
        g[x + i + 1][y] += inc;
        g[x + i + 1][y + i + 1] += inc;
        if (y - i - 1 >= 0) {
            g[x + i + 1][y - i - 1] += inc;
        }
        if (x - i - 1 >= 0) {
            g[x - i - 1][y] += inc;
            g[x - i - 1][y + i + 1] += inc;
            if (y - i - 1 >= 0) {
                g[x - i - 1][y - i - 1] += inc;
            }
        }
    }
}

void dfs(int s, int n, int w, map<string, long long> &dict) {
    if (s == n) {
        string s = ""; 
        for (int i = 0; i < n; i++) {
            for (int j = 0; j < N; j++) {
                if (g[i][j] == -1) {
                    s = s + str.substr(j, 1);
                    break;
                }
            }
        }
        dict[s] = 1;
        return;
    }

    for (int i = 0; i < N; i++) {
        if (!g[s][i]) {
            g[s][i] = -1;
            // set attack area
            setArea(s, i, N, w, 1);
            
            dfs(s + 1, n, w, dict);
            g[s][i] = 0;
            // unset  attack area
            setArea(s, i, N, w, -1);
        }
    }
}

int main()
{
    long long total = 0;
    for (int w = 1; w < N - 1; w++) {
        long long ans = 0;
        map<string, long long> d1, d2;
        int len = N - w;
        dfs(0, len, w, d1);

        map<string, long long>::iterator it, it2;
        for (int i = 0; i < N - len; i++) {
            string s2;
            d2.clear();
            for (it = d1.begin(); it != d1.end(); it++) {
                s2 = (it->first).substr(1, (it->first).size()-1); 
                d2[s2] = 0;
            }

            for (it = d1.begin(); it != d1.end(); it++) {
                s2= (it->first).substr(1, (it->first).size()-1);
                d2[s2] += it->second;
                it->second = 0;
            }

            for (it = d1.begin(); it != d1.end(); it++) {
                s2 = (it->first).substr(0, (it->first).size() - 1);
                it2 = d2.find(s2);
                if (it2 != d2.end()) {
                    it->second += it2->second;
                }
            }
        }

        for (it = d1.begin(); it != d1.end(); it++) {
            ans += it->second;
        }

        total += ans;

        printf("%d %d: %lld\n", N, w, ans);
    }

    total += 365596LL + 11112006825558016LL;

    cout << "Calvin got: " << total << endl;

    return 0;
}
